package com.gameapplet.util.encrypte;


import com.alibaba.fastjson.JSONObject;

public class DecryptUtils {

    private final static String PUBLICKEY="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDL9g1etkkJHIRfpz4DYSOBuHWZrEZU9Mnwrv5OtqipyXi/rELj9wrKpDPCffbfxH9FvidxwHHubRk2+3r3ndK/aD86Rnp6t+cH0U74zvXgIRrowKSUO3wI58SVeay8zm4Vy00mu6RyNZ/f8wz2tXnX7bVoWRkP/HddUQ114xWinQIDAQAB";
//    private final static String PRIVATEKEY="MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAMv2DV62SQkchF+nPgNhI4G4dZmsRlT0yfCu/k62qKnJeL+sQuP3CsqkM8J99t/Ef0W+J3HAce5tGTb7eved0r9oPzpGenq35wfRTvjO9eAhGujApJQ7fAjnxJV5rLzObhXLTSa7pHI1n9/zDPa1edfttWhZGQ/8d11RDXXjFaKdAgMBAAECgYB1Mot4MtJA1AwUUqtFkdmvPmkExoMbahVnoYYrgLXl6gjiSn+dMmUXD8dWKL9k0So4zw0nReexkyr79wEvq5ZesoXT7qtm3tqmYvBI9vzd50nMG37rcmAzDQ9RsOV5xtdFNQ4fOO6nOFTaHInLgMAepUyM+t4I6tDl2EYeTxxSGQJBAPcYu5VB9It6+WQx50hBzNk0I10nO/PQj5H4+GvxEHQgUOS/NvKSzzkXik++bNtlAdWt9YtDEunO5j84Wtq6KD8CQQDTT23zwDPEIUv97yDJMHInLYPxKsUGpG9jSzGWyXR/ftZCsw1PEohwtdZlimNUoAloyA/QryVoFVL9yshAZV4jAkAZzOhRRmi9Y6LEtn06yzwTdeE3adBVvfIvwLpXsv0P0wv/RoP7Qh8HDBEyEGUXZ22QnTBlUSSZazQZZ838xrFLAkAH+ujxGqIZ1xQSm/RGBNFaz2o7Ml1MeetG+bD+u87tfbHDxRVMliuW7hcRsJ89s+mHDn8iZ2rnOl7u/LiBThK3AkBihYC8bJsaxm0Xk9EElp9/mLMjuEqWrahpKJDqVYk782ZvciJMkQeMwW8WLLJyInNCNVmCO8vsH6CmtLOvMBGU";
    private final static String PRIVATEKEY="-----BEGIN RSA PRIVATE KEY-----MIICXQIBAAKBgQCk7WKdggwBOtteLL5sPom8RYCjuw0hy6R1jH39tCaep1Dns02bi4CYHk2dSR / t0ABgF5pHYeMxHa74Dp6Z6SjfAKMUu53BbTR615ehK + 03BjtzJzviTF1 / NtLmGaR3aawrDp7oQgq33dfIYbWLuAMkHNiWaoXaGyHh3a8jS2vxfQIDAQABAoGAIKRnLzts + tVWU5ZRfgUGp7 + tzToZSEYQ378VtJ / yQNZmueUQCCgdJH5i6C1v51aSrHIfc99Y4wC3/ 5qNI3M1RlRpIakmcaiEv1m6huDPLKFq6Y1e+ AZ0Cb0xo3bny + VTOvfGgcAdSa6++K47bGaxyKzwGeNZQkltm5sgbVcKvkECQQDVjWbSU8P8nDb+TP5Aqr + DaMVA425wv2ra2jhxd6KqKxgHHB7yYWlODiYNrtALOEG9zfSpHVQWhZpiKq8XcWwRAkEAxbWzPAqZxaZ / XTs65uCL0 + iqif0qCSDUNis61wYm2UwOh4LqBZIFop94B3ybEXbCvUl0v26H0fgXjFUErvlKrQJBAKjbAe5U5accLi + t2WxwlrXlZfME4hKsiGU8H10455n+ MSWOCrpEY + ugLF6tVztH5FOcQlRmKFMWmRf + ACxdNsECQDBjkEKZtZkSbwm6fWgUfSSYRWUQeUFSr52yZuxJrShx3Px9phlG6 + opbY8niCx2DKOXXuObgdJ6DglipYrNqOECQQCndP + zU / jwlvjQzEabKdP05uFc5JV6ySFBQwuoENbEvW3uz + Yz31xDYbrwIzrysVDovlj0ExL6LC + JRvpJmHcN-----END RSA PRIVATE KEY-----";
//    public static void main(String[] args) throws Exception{
//        RSAUtils.getKeys();
//    }

    public static String decrypted(String date){
        try {
            System.out.println(date);
            String result = RSAUtils.decryptByPrivateKey(date, PRIVATEKEY);
            JSONObject jsonObject = JSONObject.parseObject(result);
            String AESKEY = jsonObject.getString("publickey");
            String endate = jsonObject.getString("date");
            String dedate = AESUtils.decryptData(AESKEY,endate);
            return dedate;
        }
        catch (Exception e){
            e.printStackTrace();
            return "创建挑战失败";
        }
    }



}
